<?php
/**
 * Created by PhpStorm.
 * User: pc
 * Date: 2019/8/6
 * Time: 2:05
 */

namespace app\admin\model;


class ApprovalLeave extends Base
{
    /**
     * 获取列表
     * $t : 1获取列表 2导出
     */
    public function getList($t,$map,$query = [])
    {
        if($t == 1) {
            $list = $this->where($map)->order('apply_time desc')->paginate(10,false,['query' => $query]);
        }else {
            $list = $this->where($map)->order('apply_time desc')->select();
        }
        $typeList = LeaveConfig::where('status',1)->field('id,name')->select();
        $type = [];
        foreach ($typeList as $value) {
            $type[$value['id']] = $value['name'];
        }
        foreach ($list as $key => $value) {
            $status = [0 => "待审批", 1 => "审批通过", 2=> "审批不通过", 3=>"进行中"];
            $value['status_text'] = $status[$value['status']];
//            $type = [1 => "事假", 2 => "护理假", 3 => "病假", 4 => "丧假", 5 => "工伤假", 6 => "产假", 7 => "婚嫁假",
//                8 => "哺乳假",9 => "年假",10 => "探亲假",11 => "独生子女假",12 => "育儿假",13 => "疗休养假"];
            $value['type_text'] = isset($type[$value['type']]) ? $type[$value['type']] : "无";
            $user = $this->getUser($value['apply_user']);
            $value['apply_name'] = $user ? $user['name'] : "无该用户信息";
            $value['start_time_text'] = date("Y-m-d H:i",$value['start_time']);
            $value['end_time_text'] = date("Y-m-d H:i",$value['end_time']);
            $value['apply_time_text'] = date("Y-m-d H:i",$value['apply_time']);
        }
        return $list;
    }
}